package com.ss.android.wenda.c;

import android.content.res.Resources;
import android.net.Uri;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.bytedance.common.utility.UIUtils;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.ui.MultiStyleTextView;
import com.ss.android.article.browser.R;
import com.ss.android.image.AsyncImageView;
import com.ss.android.image.Image;
import com.ss.android.image.FrescoUtils;
import com.ss.android.k.dd;
import com.ss.android.wenda.a.i;
import com.ss.android.wenda.answer.detail2.WDFontUtils;
import com.ss.android.wenda.model.Answer;

public final class c extends dd {
    private int c;
    private i d;

    public c(int arg2, i arg3) {

        this.c = 0;
        this.c = arg2;
        this.d = arg3;
    }

    public final void a(Object arg10) {
        i v6;
        View v0_1;
        View.OnClickListener v8 = null;
        int v2 = 2;
        int v1 = 15;
        int v3 = 3;
        if((arg10 instanceof Answer)) {
            Resources v4 = this.a().getResources();
            int v5 = AppData.getInstance().mFontSizePref;
            int v0 = this.a().getId();
            if(v0 == R.id.user_avatar) {
                com.ss.android.k.d.c v2_1 = this.c();
                String v1_1 = ((Answer)arg10).mUser == null ? "" : ((Answer)arg10).mUser.mAvatarUrl;
                if((v2_1.a instanceof AsyncImageView)) {
                    v0_1 = v2_1.a;
                    ((AsyncImageView)v0_1).setPlaceHolderImage(com.ss.android.article.browser.R.color.bg_place_holder);
                    ((AsyncImageView)v0_1).setUrl(v1_1);
                }
                else if((v2_1.a instanceof ImageView)) {
                    FrescoUtils.load((ImageView) v2_1.a, Uri.parse(v1_1), R.color.bg_place_holder, ((FrescoUtils.ImageLoaderWithRetry)null));
                }

                v2_1.a(v8);
            }
            else {
                if(v0 == R.id.user_name) {
                    v0_1 = this.b().a.findViewById(com.ss.android.article.browser.R.id.user_name);
                    if(((Answer)arg10).mUser == null || (TextUtils.isEmpty(((Answer)arg10).mUser.mUserName))) {
                        this.c().c(com.ss.android.article.browser.R.string.unknown_user);
                    }
                    else {
                        this.c().a(((Answer)arg10).mUser.mUserName).a(v8);
                    }

                    if(((Answer)arg10).mUser == null || ((Answer)arg10).mUser.mIsVerify == 0) {
                        ((TextView)v0_1).setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
                    }
                    else {
                        ((TextView)v0_1).setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.all_newv, 0);
                    }

                    if(((Answer)arg10).mUser != null && !android.support.design.a.isTextEmpty(((Answer)arg10).mUser.mUserIntro)) {
                        UIUtils.setTopMargin(v0_1, 0f);
                        return;
                    }

                    UIUtils.setTopMargin(v0_1, 8f);
                    return;
                }

                if(v0 == R.id.user_intro) {
                    if(((Answer)arg10).mUser != null && !TextUtils.isEmpty(((Answer)arg10).mUser.mUserIntro)) {
                        this.c().d(0).a(((Answer)arg10).mUser.mUserIntro).a(v8);
                        return;
                    }

                    this.c().d(4);
                    return;
                }

                if(v0 == R.id.abstract_layout) {
                    if(((Answer)arg10).mAnswerAbstract != null && !TextUtils.isEmpty(((Answer)arg10).mAnswerAbstract.mContent)) {
                        this.c().d(0);
                        v0_1 = this.a().findViewById(com.ss.android.article.browser.R.id.abstract_text);
                        if(this.c == v2) {
                            if(this.d == null) {
                                v1 = v3;
                            }
                            else {
                                v6 = this.d;
                                if(v6.a == null) {
                                    v1 = v3;
                                }
                                else {
                                    v3 = v6.a.optInt("more_list_answer_text_max_count", v3);
                                    if(v3 <= v1) {
                                        v1 = v3 < v2 ? v2 : v3;
                                    }
                                }
                            }
                        }
                        else if(((Answer)arg10).hasThumbImage()) {
                            if(this.d != null) {
                                v6 = this.d;
                                if(v6.a != null) {
                                    v3 = v6.a.optInt("list_answer_has_img_text_max_count", v3);
                                    if(v3 <= v1) {
                                        v1 = v3 < v2 ? v2 : v3;
                                    }

                                    v3 = v1;
                                }
                            }

                            v1 = v3;
                        }
                        else {
                            if(this.d == null) {
                                v1 = 9;
                            }else {
                                i v2_2 = this.d;
                                if (v2_2.a == null) {
                                    v1 = 9;
                                } else {
                                    v2 = v2_2.a.optInt("list_answer_text_max_count", 9);
                                    if (v2 > v1) {
                                    } else if (v2 < v3) {
                                        v1 = v3;
                                    } else {
                                        v1 = v2;
                                    }
                                }
                            }
                        }

                        ((MultiStyleTextView)v0_1).setMaxLines(v1);
                        ((MultiStyleTextView)v0_1).a(((Answer)arg10).mAnswerAbstract.mContent, "全文");
                        ((MultiStyleTextView)v0_1).setContentTextSize(((float)WDFontUtils.d[v5]));
                        ((MultiStyleTextView)v0_1).setSuffixTextSize(((float)WDFontUtils.d[v5]));
                        ((MultiStyleTextView)v0_1).setContentTextColor(v4.getColor(com.ss.android.article.browser.R.color.ssxinzi1));
                        ((MultiStyleTextView)v0_1).setSuffixTextColor(v4.getColor(com.ss.android.article.browser.R.color.update_comment_more_text_selector));
                        return;
                    }

                    this.c().d(8);
                    return;
                }

                if(v0 != R.id.thumb_container) {
                    return;
                }

                if(!((Answer)arg10).hasThumbImage()) {
                    this.c().d(8);
                    return;
                }

                com.ss.android.k.d.c v1_2 = this.c().d(0);
                Object v0_2 = ((Answer)arg10).mAnswerAbstract.mThumbImageList.get(0);
                if((v1_2.a instanceof AsyncImageView)) {
                    View v1_3 = v1_2.a;
                    ((AsyncImageView)v1_3).setPlaceHolderImage(com.ss.android.article.browser.R.color.bg_place_holder);
                    ((AsyncImageView)v1_3).setImage(((Image)v0_2));
                    return;
                }

                if(!(v1_2.a instanceof ImageView)) {
                    return;
                }

                FrescoUtils.load((ImageView) v1_2.a, ((Image)v0_2));
            }
        }
    }
}

